package Servlet;

import doman.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

@WebServlet("/ckStudent")
public class ckStudent extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=UTF-8");
        BufferedReader br = new BufferedReader(new FileReader("D:\\sut.txt"));
      //  ArrayList<Student> list = new ArrayList<>();
        PrintWriter pw = resp.getWriter();
        String line;
        while((line = br.readLine()) != null) {
//            Student stu = new Student();
//            String[] arr = line.split(",");
//            stu.setName(arr[0]);
//            stu.setAge(arr[1]);
//            stu.setScore(arr[2]);
//            list.add(stu);
//            pw.write(s.getName() + "," + s.getAge() + "," + s.getScore());
            pw.write(line);
            pw.write("<br>");
        }
        br.close();
//        for(Student s : list) {
//        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
